package services
{

	import com.adobe.cairngorm.business.*;
	
	import flash.events.*;
	
	import mx.events.*;
	import mx.messaging.Channel;
	import mx.messaging.ChannelSet;
	import mx.messaging.channels.AMFChannel;
	import mx.rpc.remoting.RemoteObject;
	import mx.utils.UIDUtil;

	public class ApplicationServices extends ServiceLocator
	{
		[Bindable]
		public var configService:RemoteObject;

		[Bindable]
		public var gameService:RemoteObject;

		[Bindable]
		public var cmsService:RemoteObject;

		[Bindable]
		public var avatarService:RemoteObject;

		[Bindable]
		public var userService:RemoteObject;

		[Bindable]
		public var cardService:RemoteObject;

		[Bindable]
		public var bookService:RemoteObject;

		[Bindable]
		public var messageService:RemoteObject;

		[Bindable]
		public var eventService:RemoteObject;

		[Bindable]
		public var adminUserService:RemoteObject;

		[Bindable]
		public var logService:RemoteObject;

		[Bindable]
		public var applyClassService:RemoteObject;
		
		[Bindable]
		public var applyPayService:RemoteObject;
		
		[Bindable]
		public var exampleService:RemoteObject;

		private var cs:ChannelSet;
		private var endpointURL:String;

		public function ApplicationServices()
		{
			super();
			this.endpointURL = "http://localhost/amfphp/";
			this.cs = new ChannelSet();
			var id:String = UIDUtil.createUID();
			var customChannel:Channel = new AMFChannel(id, this.endpointURL);
			customChannel.requestTimeout = 7;
			this.cs.addChannel(customChannel);

			this.CreateUserService();
			this.CreateAvatarService();
			this.CreateGameService();
			this.CreateConfigService();
			this.CreateCMSService();
			this.CreateBookService();
			this.CreateCardService();
			this.CreateMessageService();
			this.CreateActivityService();
			this.CreateAdminUserService();
			this.CreateLogService();
			this.CreateApplyClassService();
			this.CreateApplyPayService();
			this.CreateExampleService();
		}
		
		private function CreateConfigService():void
		{
			this.configService = new RemoteObject();
			this.configService.showBusyCursor = true;
			this.configService.channelSet = this.cs;
			this.configService.destination = "amfphp";
			this.configService.source = 'ConfigService';
		}

		private function CreateGameService():void
		{
			this.gameService = new RemoteObject();
			this.gameService.showBusyCursor = true;
			this.gameService.channelSet = this.cs;
			this.gameService.destination = "amfphp";
			this.gameService.source = 'GameService';
		}

		private function CreateCMSService():void
		{
			this.cmsService = new RemoteObject();
			this.cmsService.showBusyCursor = true;
			this.cmsService.destination = "amfphp";
			this.cmsService.channelSet = this.cs;
			this.cmsService.source = 'CMSService';
		}

		private function CreateAvatarService():void
		{
			this.avatarService = new RemoteObject();
			this.avatarService.showBusyCursor = true;
			this.avatarService.destination = "amfphp";
			this.avatarService.channelSet = this.cs;
			this.avatarService.source = 'AvatarService';
		}

		private function CreateUserService():void
		{
			this.userService = new RemoteObject();
			this.userService.destination = "amfphp";
			this.userService.showBusyCursor = true;
			this.userService.channelSet = this.cs;
			this.userService.source = 'UserService';
		}

		private function CreateCardService():void
		{
			this.cardService = new RemoteObject();
			this.cardService.showBusyCursor = true;
			this.cardService.destination = "amfphp";
			this.cardService.channelSet = this.cs;
			this.cardService.source = 'CardService';
		}

		private function CreateBookService():void
		{
			this.bookService = new RemoteObject();
			this.bookService.showBusyCursor = true;
			this.bookService.channelSet = this.cs;
			this.bookService.destination = "amfphp";
			this.bookService.source = 'BookService';
		}

		private function CreateMessageService():void
		{
			this.messageService = new RemoteObject();
			this.messageService.showBusyCursor = true;
			this.messageService.channelSet = this.cs;
			this.messageService.destination = "amfphp";
			this.messageService.source = 'MessageService';
		}

		private function CreateActivityService():void
		{
			this.eventService = new RemoteObject();
			this.eventService.showBusyCursor = true;
			this.eventService.channelSet = this.cs;
			this.eventService.destination = "amfphp";
			this.eventService.source = 'EventService';
		}

		private function CreateAdminUserService():void
		{
			this.adminUserService = new RemoteObject();
			this.adminUserService.showBusyCursor = true;
			this.adminUserService.channelSet = this.cs;
			this.adminUserService.destination = "amfphp";
			this.adminUserService.source = 'AdminUserService';
		}

		private function CreateLogService():void
		{
			this.logService = new RemoteObject();
			this.logService.showBusyCursor = true;
			this.logService.channelSet = this.cs;
			this.logService.destination = "amfphp";
			this.logService.source = 'LogService';
		}

		private function CreateApplyClassService():void
		{
			this.applyClassService = new RemoteObject();
			this.applyClassService.showBusyCursor = true;
			this.applyClassService.channelSet = this.cs;
			this.applyClassService.destination = "amfphp";
			this.applyClassService.source = 'ApplyClassService';
		}
		private function CreateApplyPayService():void
		{
			this.applyPayService = new RemoteObject();
			this.applyPayService.showBusyCursor = true;
			this.applyPayService.channelSet = this.cs;
			this.applyPayService.destination = "amfphp";
			this.applyPayService.source = 'ApplyPayService';
		}
		
		/**  test  **/
		private function CreateExampleService():void
		{
			this.exampleService = new RemoteObject();
			this.exampleService.showBusyCursor = true;
			this.exampleService.channelSet = this.cs;
			this.exampleService.destination = "amfphp";
			this.exampleService.source = 'ExampleService';
		}

		
	}
}